package coreBiz

import (
	"math"
	"math/rand"
	"time"

	"github.com/spf13/cast"
)

func RandInt(l int) int {
	randSeed := rand.New(rand.NewSource(time.Now().UnixNano()))

	// 生成 100000 到 999999 之间的随机数
	m := cast.ToInt(math.Pow(10, cast.ToFloat64(l-1)))
	i := cast.ToInt(math.Pow(10, cast.ToFloat64(l))) - 1

	return randSeed.Intn(i-m+1) + m
}

func Rand(min, max int) int {
	randSeed := rand.New(rand.NewSource(time.Now().UnixNano()))
	return randSeed.Intn(max-min+1) + min
}
